package com.gitee.hermer.engine.jars.core.execute.domain;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.gitee.hermer.boot.jee.commons.collection.CollectionUtils;
import com.gitee.hermer.boot.jee.commons.utils.JsonUtils;

public class EngineParamBody<K extends String,V extends Object> extends HashMap<K, V> implements Serializable{

	protected Map<K, V> globalParams = CollectionUtils.newHashMap();
	
	public void pushGlobalParams(K key,V value){
		globalParams.put(key, value);
	}
	public void pushGlobalParams(String json){
		globalParams.putAll(JsonUtils.fromJSONToBean(json, Map.class));
	}
	public Object getGlobalParams(K key){
		return getGlobalParams(key,null);
	}
	public Object getGlobalParams(K key,V defaultValue){
		return globalParams.getOrDefault(key, defaultValue);
	}
	
	
	public String toJSONByGlobalParams(){
		return JsonUtils.toJSONString(globalParams);
	}
	
}
